package net.jankovar.spring.aspects;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

import flex.messaging.FlexContext;

@Aspect
public class InRoleAspect {
  
  @Before("@annotation(inRole)")
  public void checkUserInRole(InRole inRole) {
    if (!FlexContext.getHttpRequest().isUserInRole(inRole.value())) {
      throw new IllegalAccessError("Unsufficent priviliges");
    }
  }
  
}
